package qdu.edu.com.fushanf4.service.sort.twosort;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class SortByTextAndThenByIntWritableReducer extends Reducer<TextAndIntWritableBean, IntWritable, Text, IntWritable> {
    private final Text keyOut = new Text();

    @Override
    protected void reduce(TextAndIntWritableBean key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
        keyOut.set(key.getTwoCharacters());
        for (IntWritable valueOut : values) {
            context.write(keyOut, valueOut);
        }
    }
}
